<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<input type="hidden" id="get_error" value="${error}"/> 
        <%
        session.removeAttribute("error");
        String name=(String)session.getAttribute("username");
        
        %>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Login</title>
        <script type="text/javascript">
        window.onload = function () {
            document.getElementById("error_msg").innerHTML=document.getElementById("get_error").value;
			}
        function isEmpty(){
            if((document.getElementById("name").value)==""){
                alert("username is empty!");
                return false;
            }
            else if((document.getElementById("pwd").value)==""){
                alert("password is empty!");
              return false;  
            } 
            else return true;
        }
        </script>
        <link rel="stylesheet" type="text/css" href="main.css">
</head>
<%
if(name!=null){
	out.print("You have already login...!!!!!!!");
    response.setHeader("Refresh","1;URL=home.jsp");
}
else{
%>
<body>
<h1>welcome! please login!</h1><br>
        <label id="error_msg"></label><br>
        <form action="Login" method="post" id="loginform" onSubmit="return isEmpty()">
            <table>
                <tr><td>Username:</td><td><input type="text" name="username" id="name"></td></tr>
                <tr><td>Password:</td><td><input type="password" name="password" id="pwd"></td></tr>
            </table>
            <input type="submit" value="login">
          <a href="signup.jsp">Sign up</a>
        </form>
</body>
<%} %>
</html>